const addressAbout = {
  namespaced: true,
  mutations: {
    // 修改收货地址
    UPDATEADDRESS(state, address) {
      state.addressInfo = address
      this.commit('addressAbout/saveAddressToStorage')
    },
    // 存本地——持久化
    saveAddressToStorage(state) {
      uni.setStorageSync("addressInfo", JSON.stringify(state.addressInfo))
    }
  },
  state: {
    addressInfo: JSON.parse(uni.getStorageSync('addressInfo') || '{}'),
  },
  getters: {
    // 收货地址计算属性
    addStr(state) {
      if (state.addressInfo.provinceName === '' && state.addressInfo.cityName === '') return ''
      return state.addressInfo.provinceName + state.addressInfo.cityName + state.addressInfo.countyName + state.addressInfo.detailInfo
    }
  }
}
export default addressAbout